use std::cell::Ref;
use std::rc::Rc;
use crate::solution::Solution;

impl Solution {
    pub fn nums_same_consec_diff(n: i32, k: i32) -> Vec<i32> {
        let mut ans=Vec::new();
        for i in 0..=9{
            Solution::__dfs(n,k,i,i,1, &mut ans);
        }
        ans
    }
    pub fn __dfs(n:i32, k:i32, left:i32, current:i32, dep:i32, ans:&mut  Vec<i32>){
        if dep==n{
            if left!=0{
                ans.push(current);
            }
            return
        }
        let mut num =left+k;
        if num<10{
            Solution::__dfs(n, k, num, current+num*(10_i32.pow((dep) as u32)), dep+1, ans);
        }
        if k==0{
            return;
        }
        num =left-k;
        if num>=0{
            Solution::__dfs(n,k,num,current+num*(10_i32.pow((dep) as u32)),dep+1,ans);
        }
    }
}
#[cfg(test)]
mod p {
    use super::Solution;
    #[test]
    fn test_rs967() {
        println!("{:?}",Solution::nums_same_consec_diff(3, 7));
    }
}